<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{margin: 0;padding: 0;}
    .title {
      display: inline-block;
      padding: 10px;
      cursor: pointer;
    }
    .title:hover {
      background: #ccc;
    }
    ul {
      list-style: none;
    }
    ul.hide {
      display: none;
    }
    ul.show {
      display: block;
    }
    ul > li {
      margin: 20px;
      padding: 20px;
      border: 1px solid red;
    }
  </style>
</head>
<body>
  <div class="wrapper">
    <div class="title">点我</div>
    <ul class="show">
      <li>小刚</li>
      <li>小明</li>
      <li>小红</li>
    </ul>
  </div>
  <script>
    const title = document.querySelector('.title')
    const ul = document.querySelector('ul')

    title.addEventListener('click', () => {
      if (ul.classList.contains('show')) {
        ul.classList.remove('show')
        ul.classList.add('hide')
      } else {
        ul.classList.remove('hide')
        ul.classList.add('show')
      }
    })

  </script>
</body>
</html>